﻿@model List<Genewiz.Entity.CtrlActionEntity>
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <link href="@Url.Content("~/Style/OrderForm.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.7.2.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/main.js")" type="text/javascript"  language="javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.20.custom.js")" type="text/javascript"  language="javascript"></script>
    <script src="@Url.Content("~/Scripts/RoleManager.js")" type="text/javascript"  language="javascript"></script>
    <title>Index</title>
</head>
<body>
    <div>
        <input type="button" id="InitializeRole" value="Intialize Role Parameters" onclick="return SaveRoleInfo();" />
        @* <script src='@Url.Action("click")' type="text/javascript"></script>*@
        <table style="width: 100%">
            <tr style="font-weight: bold; color: Blue;">
                <td>
                    Controller Name
                </td>
                <td>
                    Cotroller Description
                </td>
                <td>
                    Action
                </td>
                <td>
                    Act Description
                </td>
                <td>
                    Is Allow All Role
                </td>
            </tr>
            @foreach (var m in Model)
            {
                <tr style="font-size: 13px;">
                    <td>@m.ControllerName
                    </td>
                    <td>@m.CtrlDescription
                    </td>
                    <td>@m.ActionName
                    </td>
                    <td>@m.ActDescription
                    </td>
                    <td>
                        @if (m.IsAllowAllRole == true)
                        {
                            <span style="color: Red;">true</span>
                        }
                        else
                        { 
                            <span>false</span>
                        }
                    </td>
                </tr>
            }
        </table>
        <hr />
         Role Name:  @Html.DropDownList("roleList", (List<SelectListItem>)ViewData["maintainRole"])
          @*  @foreach (var re in ((List<Genewiz.Entity.RoleEntity>)ViewData["ListRole"]))
            {
                <input type="checkbox" value="@re.RoleID" />@re.RoleName 
            }*@
            <table id="rlist"  >
            @foreach (var item in ((List<Genewiz.Entity.CtrlActionEntity>)ViewData["ListControllerAction"])
                .Select(x => new { x.ControllerName, x.CtrlDescription }).Distinct())
            { 
                <tr>
                    <td>
                        <strong>
                            @{   var CtrlActionID =
                               ((List<Genewiz.Entity.CtrlActionEntity>)ViewData["ListControllerAction"]).
                               Where(x => x.ControllerName == item.ControllerName && x.ActionName == item.ControllerName).Select(x => x.CtrlActionID).ToArray()[0];
                             
                                <input type="checkbox"  value="@CtrlActionID" />
                            }
                            @item.CtrlDescription
                        </strong>
                        <br />
                        @foreach (var act in ((List<Genewiz.Entity.CtrlActionEntity>)ViewData["ListControllerAction"]).Where(x => x.ControllerName == item.ControllerName && x.ActionName != x.ControllerName))
                        {
                            <input type="checkbox" value="@act.CtrlActionID" />@act.ActDescription 
                        }
                    </td>
                </tr>
            }
        </table>

           <input type="button" id="maintainRole" value="Update" onclick="return updateRole();" />
        <hr />
         <div id="loading" style="display:none;">
       <img src="../../Style/images/loading.gif"  alt=""/>Saving data....
    </div>

        User Name:@Html.DropDownList("userList", (List<SelectListItem>)ViewData["ListUser"])
        <div id="role">
            Role Name: @* @Html.DropDownList("roleList", (List<SelectListItem>)ViewData["ListRole"])*@
            @foreach (var re in ((List<Genewiz.Entity.RoleEntity>)ViewData["ListRole"]))
            {
                <input type="checkbox" value="@re.RoleID" />@re.RoleName 
            }
        </div>
        <input type="checkbox" id="addCustomRole" value="addCustomRole" />Add Custom Permission
        <table id="RoleList" style="display: none;">
            @foreach (var item in ((List<Genewiz.Entity.CtrlActionEntity>)ViewData["ListControllerAction"])
                .Select(x => new { x.ControllerName, x.CtrlDescription }).Distinct())
            { 
                <tr>
                    <td>
                        <strong>
                            @{   var CtrlActionID =
                               ((List<Genewiz.Entity.CtrlActionEntity>)ViewData["ListControllerAction"]).
                               Where(x => x.ControllerName == item.ControllerName && x.ActionName == item.ControllerName).Select(x => x.CtrlActionID).ToArray()[0];
                             
                                <input type="checkbox"  value="@CtrlActionID" />
                            }
                            @item.CtrlDescription
                        </strong>
                        <br />
                        @foreach (var act in ((List<Genewiz.Entity.CtrlActionEntity>)ViewData["ListControllerAction"]).Where(x => x.ControllerName == item.ControllerName && x.ActionName != x.ControllerName))
                        {
                            <input type="checkbox" value="@act.CtrlActionID" />@act.ActDescription 
                        }
                    </td>
                </tr>
            }
        </table>
        <br />
        <input type="button" id="SaveRole" value="Save" onclick="return SelectedRole();" />
    </div>

</body>
</html>
